package com.yunji.web.base;

import com.yunji.base.business.StaffSiteBusiness;
import com.yunji.base.domain.StaffSiteDO;
import com.yunji.base.dto.StaffSiteQueryDTO;
import com.yunji.common.annotation.Log;
import com.yunji.common.base.BaseController;
import com.yunji.common.base.response.Response;
import com.yunji.common.base.response.ResponseHelper;
import com.yunji.common.enums.common.BusinessType;
import com.yunji.common.utils.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @version 1.0
 * @Project: yunji-coffee
 * @Package com.yunji.web.user
 * @FileName StaffSiteController.java
 * @Copyright Copyright © 2024 云集互联. All Rights Reserved
 * Company		com
 * @CreateTime 2024-04-08 13:50:12
 * @Description 员工站点关联交互
 * @Modification Author                    History Time			Version				Description
 * --------------------------------------------------------------------------------
 * HuaAo				2024-04-03 13:50:12		1.0					1.0 Version
 * @since JDK 1.8.0_202
 */
@Api(tags = "管理端-员工站点关联管理")
@RestController
@RequestMapping("/container/staffSite")
public class StaffSiteController extends BaseController {

    @Resource
    StaffSiteBusiness business;

    /**
     * 查询员工站点关联列表
     */
    @ApiOperation("查询员工站点关联列表")
    @GetMapping("/list")
    public Response<List<StaffSiteDO>> list(StaffSiteQueryDTO staffSite) {
        List<StaffSiteDO> list = business.search(staffSite);
        return ResponseHelper.successWithPage(list);
    }

    /**
     * 导出员工站点关联列表
     */
    @ApiOperation("导出员工站点关联列表")
    @Log(title = "员工站点关联", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(StaffSiteQueryDTO staffSite) {
        List<StaffSiteDO> list = business.search(staffSite);
        ExcelUtil<StaffSiteDO> util = new ExcelUtil<StaffSiteDO>(StaffSiteDO.class);
        util.exportExcel(response, list, "员工站点关联数据");
    }

    /**
     * 获取员工站点关联详细信息
     */
    @ApiOperation("获取员工站点关联详细信息")
    @GetMapping(value = "/{id}")
    public Response<StaffSiteDO> getInfo(@PathVariable("id") Long id) {
        return ResponseHelper.success(business.select(id));
    }

    /**
     * 新增员工站点关联
     */
    @ApiOperation("新增员工站点关联")
    @Log(title = "员工站点关联", businessType = BusinessType.INSERT)
    @PostMapping
    public Response<Long> add(@RequestBody StaffSiteDO staffSite) {
        return ResponseHelper.success(business.create(staffSite));
    }

    /**
     * 修改员工站点关联
     */
    @ApiOperation("修改员工站点关联")
    @Log(title = "员工站点关联", businessType = BusinessType.UPDATE)
    @PutMapping
    public Response<String> edit(@RequestBody StaffSiteDO staffSite) {
        business.update(staffSite);
        return ResponseHelper.success("修改成功");
    }

    /**
     * 删除员工站点关联
     */
    @ApiOperation("删除员工站点关联")
    @Log(title = "员工站点关联", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public Response<String> remove(@PathVariable Long[] ids) {
        business.delete(ids);
        return ResponseHelper.success("删除成功");
    }
}
